package org.gwtunclutter.client;

import com.google.gwt.user.client.ui.UIObject;
import com.google.gwt.user.client.ui.Widget;

/**
 * Date: Sep 21, 2007
 * Time: 8:26:55 PM
 *
 * @author Alex
 */
public class WidgetStyle {
  String primaryStyleName, width, height;

  public WidgetStyle() {
  }

  public WidgetStyle(String styleName, String width, String height) {
    this.primaryStyleName = styleName;
    this.width = width;
    this.height = height;
  }

  public WidgetStyle(String width, String height) {
    this.width = width;
    this.height = height;
  }

  public WidgetStyle(String styleName) {
    this.primaryStyleName = styleName;
  }

  public String getHeight() {
    return height;
  }

  public void setHeight(String height) {
    this.height = height;
  }

  public String getPrimaryStyleName() {
    return primaryStyleName;
  }

  public void setPrimaryStyleName(String primaryStyleName) {
    this.primaryStyleName = primaryStyleName;
  }

  public String getWidth() {
    return width;
  }

  public void setWidth(String width) {
    this.width = width;
  }

  /** Applies the style to the widget and returns it (for chaining) */
  public Widget apply(Widget widget) {
    if (width != null)
      widget.setWidth(width);
    if (height != null)
      widget.setHeight(height);
    if (primaryStyleName != null)
      widget.setStyleName(primaryStyleName);
    return widget;
  }
}
